package com.wkhyapp.lm.adapter;

import android.content.Context;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;

import com.wkhyapp.lm.R;
import com.wkhyapp.lm.adapter.base.HolderEntity;
import com.wkhyapp.lm.adapter.base.MirAdapter;
import com.wkhyapp.lm.http.vo.Fans;
import com.wkhyapp.lm.utils.ImageLoadUtil;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by fang on 2021/10/19.
 */

public class ShareGoodsImgApater extends MirAdapter<String> {

    public ShareGoodsImgApater.callBack mCallBack;
    private Map<Integer, Boolean> isCheck = new HashMap<Integer, Boolean>();

    public ShareGoodsImgApater(Context context, List<String> mDatas, int itemLayoutId) {
        super(context, mDatas, itemLayoutId);
    }



    @Override
    public void convert(final HolderEntity helper, String item) {

        ImageView img_iv = helper.getView(R.id.img_iv);
        ImageLoadUtil.setRoundImage_Normal(mContext,item,4,img_iv);
        CheckBox checkBox = helper.getView(R.id.qx_cb);
        isCheck.put(helper.getPosition(),true);

        checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if(isChecked){
                    isCheck.put(helper.getPosition(),true);
                }else{
                    isCheck.put(helper.getPosition(),false);
                }
                notifyDataSetChanged();
            }
        });
    }

    public void  setCallBack(ShareGoodsImgApater.callBack callBack){
        this.mCallBack = callBack;
    }


    public interface  callBack{
        void check(Fans item);
    }
}
